<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="description" content="A fully featured admin theme which can be used to build CRM, CMS, etc.">
    <meta name="author" content="Coderthemes">

    <link rel="stylesheet" href="/adminstatic/base/base.css"/>
    <script src="/adminstatic/base/baseCss.js"></script>

    <style type="text/css">
        html, body {
            background: #fff;
        }

        .layui-input-block {
            margin-left: 0;
        }
    </style>
</head>

<body class="fixed-left">

<!-- Begin page -->
<div id="wrapper" style="overflow: auto;">

    <div class="container">

        <div class="panel panel-default" style="box-shadow: none">
            <div class="panel-body">
                <form class="layui-form" action="">
                    <div id="inputForm" class="form-horizontal">
                        <input type="hidden" name="id" value="<%=id%>"/>
                        <input type="hidden" name="orders" value="<%=orders%>"/>
                        <div class="row" style="padding:0 20px">
                            <div class="form-group">
                                <div class="col-xs-12 col-md-4 ">
                                    <label for="title"><small class="notNullFlag">*</small> 分类名称</label>
                                    <input class="form-control" type="text" id="title" name="title"
                                           value="<%=title%>" required>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-xs-12 col-md-4 ">
                                    <label for="name"><small class="notNullFlag">*</small> 英文名称</label>
                                    <input class="form-control" type="text" id="name" name="name"
                                           value="<%=name%>" required>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-xs-12 col-md-4 ">
                                    <label for="type"><small class="notNullFlag">*</small> 英文分类名称</label>
                                    <input class="form-control" type="text" id="type" name="type"
                                           value="<%=type%>" required>
                                </div>
                            </div>

                        </div>

                    </div>
                </form>
                <div id="actions">
                    <button type="button" class="layui-btn layui-btn-normal" id="submitBtn">保存</button>
                    <button type="button" class="layui-btn layui-btn-primary" onclick="closeIframe()">取消</button>
                </div>
            </div><!-- panel-body -->
        </div> <!-- panel -->

    </div> <!-- container -->

</div>
<!-- END wrapper -->

<script src="/adminstatic/base/base.js"></script>
<script type="text/javascript">
    var orders = $("input[name='orders']").val();
    console.log(orders)
    $("#submitBtn").click(function () {
        var id = $("input[name='id']").val();
        var title = $("input[name='title']").val();
        var name = $("input[name='name']").val();
        var type = $("input[name='type']").val();
        console.log( id, title, name,type)
        if (!vaildeParam(title)) {
            layer.msg("分类名称不能为空", {icon: 5});
            return;
        }
        if (!vaildeParam(name)) {
            layer.msg("英文名称不能为空", {icon: 5});
            return;
        }
        if (!vaildeParam(type)) {
            layer.msg("英文分类名称不能为空", {icon: 5});
            return;
        }
        // if (!vaildeParam(order)) {
        //     layer.msg("分类序号不能为空", {icon: 5});
        //     return;
        // }
        //
        // if (parseInt(order) <= 0){
        //     layer.msg("分类序号必须大于0", {icon: 5});
        //     return;
        // }

        var api = '/admin/product_category/update';
        var data = {
            "id": id,
            "title": title,
            "name": name,
            "type": type
        }

        postJSON(api, data, function (res) {
            cleanSuccess(res)
        })

    })
</script>
</body>
</html>